package com.jewelry.web.action;

import java.util.List;

import com.jewelry.service.ICustomerService;
import com.jewelry.vo.CustomerVO;

public class CustomerAction extends HttpAction {

	private static final long serialVersionUID = 7486760748433722843L;

	private ICustomerService customerService;

	public ICustomerService getCustomerService() {
		return customerService;
	}

	public void setCustomerService(ICustomerService customerService) {
		this.customerService = customerService;
	}

	private CustomerVO customer;

	private List<CustomerVO> customerList;

	public List<CustomerVO> getCustomerList() {
		return customerList;
	}

	public void setCustomerList(List<CustomerVO> customerList) {
		this.customerList = customerList;
	}

	public CustomerVO getCustomer() {
		return customer;
	}

	public void setCustomer(CustomerVO customer) {
		this.customer = customer;
	}

	// =================================================================

	public String queryCustomerList() {
		if (customer == null) {
			customer = new CustomerVO();
		}
		customerList = customerService.getCustomerListByPage(customer);
		return SUCCESS;
	}

	public String addCustomerPage() {
		if (customer == null) {
			customer = new CustomerVO();
		}
		customer.setCustomerid(customerService.getCustomerID());
		return SUCCESS;
	}

	public String addingCustomer() {
		customerService.addCustomer(customer);
		message = "客户名:" + customer.getCustomerName() + "客户号:"
				+ customer.getCustomerid() + "保存成功!";
		customer = new CustomerVO();
		customer.setCustomerid(customerService.getCustomerID());
		return SUCCESS;
	}

}
